classdef ziDemods < ziStreamNode
    %ZIDEMODS Summary of this class goes here
    %   Detailed explanation goes here
    
    properties(SetAccess = immutable)
        domain
        isTrigNode
        toSignalString
        
        toString
        toDataString
        toSwprString
        toDispString
    end
    
    methods
        function obj = ziDemods(node, index, signal, fft_option, math_operation)
            obj@ziStreamNode(node, index, signal, fft_option, math_operation);
            
            if ~isempty(signal)
                prefix = 'sample.';
            else
                prefix = 'sample';
            end
            
            if ~isempty(fft_option)
                fft_option = ['.fft.' fft_option];
                obj.domain = 'Frequency';
            else
                fft_option = '';
                obj.domain = 'Time';
            end
            
            if ~isempty(math_operation)
                operation = ['.' math_operation];
            else
                operation = '';
            end
            
            if isempty(fft_option) && isempty(math_operation)
                obj.isTrigNode = true;
            else
                obj.isTrigNode = false;
            end
            
            index1 = char(index+1); 
            
            if contains(signal, 'AuxIn0')
                signal1 = strrep(signal, 'AuxIn0', 'AuxIn1');
            elseif contains(signal, 'AuxIn1')
                signal1 = strrep(signal, 'AuxIn1', 'AuxIn2');
            else
                signal1 = signal;
            end
            
            obj.toString     = [ node '/' index '/'  [prefix signal]  fft_option, operation];
            obj.toDispString = [ node '/' index1 '/' [prefix signal1] fft_option, operation];
            
            obj.toDataString = strrep(obj.toString, '.', '_');
            obj.toSignalString = strrep([prefix signal fft_option operation], '.', '_');
            
            obj.toSwprString = 'demods';
        end
    end
end

